package com.common.manager;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

import com.common.model.CparamModel;
import com.framework.model.IData;
import com.framework.model.impl.DataMap;



@Component
public class CparamManager  extends BaseManager{
	
	@Override
	public void setSqlMapNameSpace() {
		this.sqlMapNameSpace = "com.common.system.model.cparam";
	}
	
	
	/**
	 * 通过传入多个KEY一次取出全部的List后封装
	 * @param modelView
	 * @param keyCodes 'key1','key2'
	 */
	public void getCparamList(ModelAndView modelView,String keyCodes){
		IData conditionObj = new DataMap();
		conditionObj.put("vkeys",keyCodes);
		List<CparamModel> paramList = super.getObjectList("getKeysList",conditionObj);
		String[] vkey = keyCodes.split(",");
		List cparamList;
		for (int i = 0; i < vkey.length; i++) {
			String attributeName = vkey[i].replace("'","");
			cparamList = new ArrayList<CparamModel>();
			for (CparamModel cparamModel : paramList) {
				if(attributeName.equals(cparamModel.getVkey())){
					cparamList.add(cparamModel);
				}
			}
			modelView.addObject(attributeName, cparamList);
		}
	}
	
}
